<?php

namespace app\common\model;

use think\Model;

class MeridConfig extends Model
{
    // 表名
    protected $name = 'merid_config';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
	    'reg_need_recommend_text',
	    'recharge_send_sms_text',
	    'level_text'
    ];
    

    CONST NEED_RECOMMEND_Y = 1;
	CONST NEED_RECOMMEND_N = 0;

	public static $needRecommendList = [
		self::NEED_RECOMMEND_Y => '是',
		self::NEED_RECOMMEND_N => '否'
	];
	
	public function getRegNeedRecommendTextAttr($value, $data) {
		$value = $value ? $value : $data['reg_need_recommend'];
		$list = self::$needRecommendList;
		return isset($list[$value]) ? $list[$value] : '';
	}

	CONST SEND_Y = 1;
	CONST SEND_N = 0;
	
	public static $sendList = [
		self::SEND_Y => '是',
		self::SEND_N => '否'
	];
	
	public function getRechargeSendSmsTextAttr($value, $data) {
		$value = $value ? $value : $data['recharge_send_sms'];
		$list = self::$sendList;
		return isset($list[$value]) ? $list[$value] : '';
	}
	
	public function getLevelTextAttr($value, $data) {
		$value = $value ? $value : $data['share_user_level'];
		$list = \app\admin\model\User::$_level;
		return isset($list[$value]) ? $list[$value] : '';
	}

}
